import 'package:flutter/material.dart';
import 'package:flutter_app/pages/home/index.dart';
import 'package:flutter_app/pages/login.dart';
import 'package:fluro/fluro.dart';
import 'package:flutter_app/routes/routes.dart';
import 'package:flutter_app/scoped_model/auth.dart';
import 'package:flutter_app/scoped_model/city.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:scoped_model/scoped_model.dart';

import 'scoped_model/filter_bar.dart';
// @dart=2.9

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    // 定义路由
    FluroRouter router = FluroRouter();
    // 配置路由
    Routes.configureRoutes(router);
    // *将model数据注入入口文件
    return ScopedModel<AuthModel>(
        model: AuthModel(),
        child: ScopedModel<CityModel>(
            model: CityModel(),
            child: ScopedModel<FilterBarModel>(
                model: FilterBarModel(),
                child: MaterialApp(
                  // home: const LoginPage(),
                  home: const HomePage(),
                  // initialRoute: Routes.home,
                  // 生成路由的回调函数
                  onGenerateRoute: router.generator,
                  // 国际化
                  localizationsDelegates: const [
                    GlobalMaterialLocalizations.delegate,
                    GlobalWidgetsLocalizations.delegate,
                    GlobalCupertinoLocalizations.delegate,
                  ],
                  supportedLocales: const [
                    Locale('zh', 'CH'),
                    Locale('en', 'US'),
                  ],
                  // title: 'Flutter Demo',
                  theme: ThemeData(
                    brightness: Brightness.light,
                    primarySwatch: Colors.green,
                    textTheme: const TextTheme(
                      bodyText2: TextStyle(fontSize: 14.0, fontFamily: 'Hind'),
                    ),
                  ),

                  debugShowCheckedModeBanner: false,
                ))));
  }
}
